package com.mixed;
import com.mixed.*;

public class MixedEncrypt {
    //private static String SavePath = "/usr/share/tomcat8/webapps/encrypt/WEB-INF/uploadEncrypt/";

    /*//RSAkeypath 为上传的RSA公钥在服务器上的位置。plainpath为上传的明文在服务器上的位置
    public static String[] mixedEncrypt(String RSAkeypath, String plainpath) throws Exception {
        String DESKey = DES.getKey();//获得DESede的密钥,base64编码
        String CipherFile = SavePath + "CipherFile.dat";
        DES.encrypt(plainpath, DESKey, CipherFile);
        String EncryptedDESkey = SavePath + "EncryptedDESkey.dat";//RSA加密后的DES密钥的位置
        RSA.FastEncrypt(DESKey, RSAkeypath, EncryptedDESkey);
        return new String[]{CipherFile, EncryptedDESkey};
    }*/

    public static String[] mixedEncryptWithKey(String publickey, String plainpath, String tmpPath) throws Exception {
        String DESKey = DES.getKey();//获得DESede的密钥,base64编码
        String CipherFile = tmpPath + "/" + "CipherFile.dat";
        DES.encrypt(plainpath, DESKey, CipherFile);
        String EncryptedDESkey = tmpPath + "/" + "EncryptedDESkey.dat";//RSA加密后的DES密钥的位置
        RSA.FastEncrypt(DESKey, publickey, EncryptedDESkey);
        return new String[]{CipherFile, EncryptedDESkey};
    }
}